<?php

require_once PATH_CLASS.'match.class.php';
require_once PATH_CLASS.'image.class.php';
require_once PATH_CLASS.'UploadHandler.class.php';

class myUploadHandler extends UploadHandler {
  
  function __construct($options = null, $initialize = true, $error_messages = null) {
    
    if(isset($_POST['id']) && $_POST['id']!=0){
      if(is_array($_SERVER) && $_SERVER['SCRIPT_FILENAME']){
        $options['upload_dir']  = (dirname($_SERVER['SCRIPT_FILENAME']).'/tmp/');
        $match=match::getMatch($_POST['id']);
        if($match){
          $rep = image::getRepertoirePhotoMatch($match);
          $options['upload_dir'] = $rep;
          
          $size = image::getImageSize(image::C_IMAGE_MINIATURE,image::C_IMAGE_MATCH);
          
          $options['image_versions'][image::C_IMAGE_MINIATURE] = array(
             'upload_dir' => $rep. image::C_IMAGE_MINIATURE
            ,'max_width'  => $size->width
            ,'max_height' => $size->height
          ); 
          
        }
      }
    }
    parent::__construct($options, $initialize, $error_messages);
  }

  function handle_form_data($file, $index) {
    //parent::handle_form_data($file, $index);
  }
}

